All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.undo.UndoManager
java.lang.Object
|
+----com.sun.java.swing.undo.AbstractUndoableEdit
|
+----com.sun.java.swing.undo.CompoundEdit
|
+----com.sun.java.swing.undo.UndoManager
- public class UndoManager
- extends CompoundEdit
- implements UndoableEditListener
Concrete subclass of CompoundEdit which can serve as an
UndoableEditListener, consolidating the UndoableEditEvents from a
variety of sources, and undoing or redoing them one at a time.
Unlike AbstractUndoableEdit and CompoundEdit, the public methods of this
class are synchronized, and should be safe to call from multiple
threads. This should make UndoManager a convenient marshall for
sets of undoable JavaBeans.
Warning: serialized objects of this class will not be compatible with
future swing releases. The current serialization support is appropriate
for short term storage or RMI between Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
-
UndoManager()
-
-
addEdit(UndoableEdit)
- If inProgress, inserts anEdit at indexOfNextAdd, and removes
any old edits that were at indexOfNextAdd or later.
-
canRedo()
- Overridden to preserve usual semantics: returns true if a redo
operation would be successful now, false otherwise
-
canUndo()
- Overridden to preserve usual semantics: returns true if an undo
operation would be successful now, false otherwise
-
canUndoOrRedo()
- Return true if calling undoOrRedo will undo or redo.
-
discardAllEdits()
- Empty the undo manager, sending each edit a die message
in the process.
-
editToBeRedone()
- Returns the the next significant edit to be redone if redo is
called.
-
editToBeUndone()
- Returns the the next significant edit to be undone if undo is
called.
-
getLimit()
- Returns the maximum number of edits this UndoManager will
hold.
-
getRedoPresentationName()
- If inProgress, returns getRedoPresentationName of the
significant edit that will be redone when redo() is invoked.
-
getUndoOrRedoPresentationName()
- Return the appropriate name for a command that toggles between
undo and redo.
-
getUndoPresentationName()
-
If inProgress, returns getUndoPresentationName of the
significant edit that will be undone when undo() is invoked.
-
redo()
- If this UndoManager is inProgress, redoes the last significant
UndoableEdit at indexOfNextAdd or after, and all insignificant
edits up to it.
-
redoTo(UndoableEdit)
- Redoes all changes from indexOfNextAdd to edit.
-
setLimit(int)
- Set the maximum number of edits this UndoManager will hold.
-
toString()
-
-
trimEdits(int, int)
- Tell the edits in the given range (inclusive) to die, and
remove them from edits.
-
trimForLimit()
- Reduce the number of queued edits to a range of size limit,
centered on indexOfNextAdd.
-
undo()
- If this UndoManager is inProgress, undo the last significant
UndoableEdit before indexOfNextAdd, and all insignificant edits back to
it.
-
undoableEditHappened(UndoableEditEvent)
- Called by the UndoabledEdit sources this UndoManager listens
to.
-
undoOrRedo()
- Undo or redo as appropriate.
-
undoTo(UndoableEdit)
- Undoes all changes from indexOfNextAdd to edit.
UndoManager
public UndoManager()
getLimit
public synchronized int getLimit()
- Returns the maximum number of edits this UndoManager will
hold. Default value is 100.
- See Also:
- addEdit, setLimit
discardAllEdits
public synchronized void discardAllEdits()
- Empty the undo manager, sending each edit a die message
in the process.
trimForLimit
protected void trimForLimit()
- Reduce the number of queued edits to a range of size limit,
centered on indexOfNextAdd.
trimEdits
protected void trimEdits(int from,
int to)
- Tell the edits in the given range (inclusive) to die, and
remove them from edits. from > to is a no-op.
setLimit
public synchronized void setLimit(int l)
- Set the maximum number of edits this UndoManager will hold. If
edits need to be discarded to shrink the limit, they will be
told to die in the reverse of the order that they were added.
- See Also:
- addEdit, getLimit
editToBeUndone
protected UndoableEdit editToBeUndone()
- Returns the the next significant edit to be undone if undo is
called. May return null
editToBeRedone
protected UndoableEdit editToBeRedone()
- Returns the the next significant edit to be redone if redo is
called. May return null
undoTo
protected void undoTo(UndoableEdit edit) throws CannotUndoException
- Undoes all changes from indexOfNextAdd to edit. Updates indexOfNextAdd accordingly.
redoTo
protected void redoTo(UndoableEdit edit) throws CannotRedoException
- Redoes all changes from indexOfNextAdd to edit. Updates indexOfNextAdd accordingly.
undoOrRedo
public synchronized void undoOrRedo() throws CannotRedoException, CannotUndoException
- Undo or redo as appropriate. Suitable for binding to an action
that toggles between these two functions. Only makes sense
to send this if limit == 1.
- See Also:
- canUndoOrRedo, getUndoOrRedoPresentationName
canUndoOrRedo
public synchronized boolean canUndoOrRedo()
- Return true if calling undoOrRedo will undo or redo. Suitable
for deciding to enable a command that toggles between the two
functions, which only makes sense to use if limit == 1.
- See Also:
- undoOrRedo
undo
public synchronized void undo() throws CannotUndoException
- If this UndoManager is inProgress, undo the last significant
UndoableEdit before indexOfNextAdd, and all insignificant edits back to
it. Updates indexOfNextAdd accordingly.
If not inProgress, indexOfNextAdd is ignored and super's routine is
called.
- Overrides:
- undo in class CompoundEdit
- See Also:
- end
canUndo
public synchronized boolean canUndo()
- Overridden to preserve usual semantics: returns true if an undo
operation would be successful now, false otherwise
- Overrides:
- canUndo in class CompoundEdit
redo
public synchronized void redo() throws CannotRedoException
- If this UndoManager is inProgress, redoes the last significant
UndoableEdit at indexOfNextAdd or after, and all insignificant
edits up to it. Updates indexOfNextAdd accordingly.
If not inProgress, indexOfNextAdd is ignored and super's routine is
called.
- Overrides:
- redo in class CompoundEdit
- See Also:
- end
canRedo
public synchronized boolean canRedo()
- Overridden to preserve usual semantics: returns true if a redo
operation would be successful now, false otherwise
- Overrides:
- canRedo in class CompoundEdit
addEdit
public synchronized boolean addEdit(UndoableEdit anEdit)
- If inProgress, inserts anEdit at indexOfNextAdd, and removes
any old edits that were at indexOfNextAdd or later. The die
method is called on each edit that is removed is sent, in the
reverse of the order the edits were added. Updates
indexOfNextAdd.
If not inProgress, acts as a CompoundEdit
- Overrides:
- addEdit in class CompoundEdit
- See Also:
- end, addEdit
getUndoOrRedoPresentationName
public synchronized String getUndoOrRedoPresentationName()
- Return the appropriate name for a command that toggles between
undo and redo. Only makes sense to use such a command if limit
== 1 and we're not in progress.
getUndoPresentationName
public synchronized String getUndoPresentationName()
-
If inProgress, returns getUndoPresentationName of the
significant edit that will be undone when undo() is invoked.
If there is none, returns AbstractUndoableEdit.UndoName
If not inProgress, acts as a CompoundEdit
- Overrides:
- getUndoPresentationName in class CompoundEdit
- See Also:
- undo, getUndoPresentationName
getRedoPresentationName
public synchronized String getRedoPresentationName()
- If inProgress, returns getRedoPresentationName of the
significant edit that will be redone when redo() is invoked.
If there is none, returns AbstractUndoableEdit.RedoName
If not inProgress, acts as a CompoundEdit
- Overrides:
- getRedoPresentationName in class CompoundEdit
- See Also:
- redo, getUndoPresentationName
undoableEditHappened
public void undoableEditHappened(UndoableEditEvent e)
- Called by the UndoabledEdit sources this UndoManager listens
to. Calls addEdit with e.getEdit().
- See Also:
- addEdit
toString
public String toString()
- Overrides:
- toString in class CompoundEdit
All Packages Class Hierarchy This Package Previous Next Index